<!DOCTYPE html>
  <?php
  $zhuti="default1";
  if(isset($_COOKIE["zhuti"])){
      $zhuti=$_COOKIE["zhuti"];
  }
  //count 求数组的长度
  echo "<br/>count(\$_POST)的长度：".count($_POST)."<br/>";
  if(count($_POST)){
//      echo "<br/>count(\$_POST)的值："."<br/>";
//      foreach($_POST as $k=>$v){
//          echo $k."-->".$v;
//      }
      $zhuti=$_POST["zhuti"];
      setcookie("zhuti",$_POST["zhuti"],time()+3600*24*30);
  }
 ?>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            .red1{
                background-color: red;
                color:yellow;
            }
            .blue1{
                background-color: blue;
                color:gray;
            }
            .default1{
                color:#005678;
            }
        </style>
    </head>
    <body class="<?php echo $zhuti;?>">
        <form action="cookie001.php" method="post">
            主题：<select name="zhuti">
                <option value="blue1">蓝色</option>
                <option value="red1">红色</option>
            </select>
            <br/>
            <input type="submit" value="确定"/>
            <p>
                cookie的使用案例
            </p>
        </form> 
    </body>
</html>
